<template>
	<view class="">
		<uni-forms :modelValue="formData">
			<uni-forms-item label="账号" username="username">
				<uni-easyinput type="text" v-model="formData.username" placeholder="请输入账号" />
			</uni-forms-item>
			<uni-forms-item label="密码" username="password">
				<input type="text" v-model="formData.password" placeholder="请输入密码" />
			</uni-forms-item>
		</uni-forms>
		<button @click="submit">登录</button>
	</view>

</template>

<script setup lang="ts">
import { compile, ref } from "vue";
import {login} from '@/api/user'
let formData = ref({
  username:'',
  password:'',
})
const submit = async () => {
  let {token , user} = await login(formData.value)
  if(token){
    uni.setStorage({
      key:'token',
      data:token,
      success(){
        uni.switchTab({
          url:'/pages/index/index'
        })
      }
    })
  }
};
</script>

<style>
.content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.logo {
  height: 200rpx;
  width: 200rpx;
  margin-top: 200rpx;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 50rpx;
}

.text-area {
  display: flex;
  justify-content: center;
}

.title {
  font-size: 36rpx;
  color: #8f8f94;
}
</style>
